<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied.  See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  -->

<section fxLayout="column" fxLayoutAlign="center center">
  <mat-spinner *ngIf="isLoading"></mat-spinner>
  <section fxFlexFill>
    <section *ngIf="!isLoading && workflowRows.length == 0" class="empty">
      There's no workflow here.
    </section>
    <section>
      <ngx-datatable
        #workflowsTable
        class="material"
        [headerHeight]="headerHeight"
        [rowHeight]="rowHeight"
        columnMode="force"
        [footerHeight]="rowHeight"
        [rows]="workflowRows"
        [sorts]="sorts"
        [limit]="20"
        [selectCheck]="checkSelectable"
      >
        <ngx-datatable-column
          name="Workflow ID"
          prop="name"
          [resizeable]="true"
          [sortable]="true"
          [draggable]="false"
          [canAutoResize]="true"
        >
          <ng-template let-row="row" ngx-datatable-cell-template>
            <a routerLink="{{ row.name }}">{{ row.name }}</a>
          </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-row-detail rowHeight="auto">
          <ng-template let-row="row" ngx-datatable-row-detail-template>
          </ng-template>
        </ngx-datatable-row-detail>
        <ngx-datatable-footer>
          <ng-template
            ngx-datatable-footer-template
            let-rowCount="rowCount"
            let-pageSize="pageSize"
            let-curPage="curPage"
          >
            <section
              class="footer"
              fxLayout="row"
              fxLayoutAlign="space-between center"
            >
              <section>{{ rowCount }} total</section>
              <section>
                <datatable-pager
                  [pagerLeftArrowIcon]="'datatable-icon-left'"
                  [pagerRightArrowIcon]="'datatable-icon-right'"
                  [pagerPreviousIcon]="'datatable-icon-prev'"
                  [pagerNextIcon]="'datatable-icon-skip'"
                  [page]="curPage"
                  [size]="pageSize"
                  [count]="rowCount"
                  [hidden]="!(rowCount / pageSize > 1)"
                  (change)="workflowsTable.onFooterPage($event)"
                >
                </datatable-pager>
              </section>
            </section>
          </ng-template>
        </ngx-datatable-footer>
      </ngx-datatable>
    </section>
  </section>
</section>
